package com.itboye.sunsunhome.util;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import com.itboye.sunsunhome.www.aq.base.MyApplication;

import android.app.AlertDialog;
import android.widget.Toast;
/***
 * 设置时间让dialog自动关闭
 * @author itboye
 *
 */
public class AutoCloseDialog {
	 private AlertDialog dialog;  
	    private ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();  
	      
	    public AutoCloseDialog(AlertDialog dialog){  
	        this.dialog = dialog;  
	    }  
	      
	    public void show(long duration){  
	        //创建自动关闭任务  
	        Runnable runner = new Runnable() {  
	            @Override  
	            public void run() {  
	                dialog.dismiss();  
	            }  
	        };  
	        //新建调度任务  
	        executor.schedule(runner, duration, TimeUnit.MILLISECONDS);  
	        dialog.show();  
	    }  
}
